// do /Users/shoude/Dropbox/eegap/EEgap_data_code_heter_SM/Code/extract_ee_2012_2022.do

/*
Check what there is in CCMS public that LBNL shared with us
*/

/*
Code structure:
Part 1. Import CCMS private data prior 09.2014: ccms_refrigerator_archived_pre_092014.csv
Part 2. Import Public data after 09.2014 stored in JSON:  p-certs-category__id__exact17-data_extracted.csv but after JSON extraction
of p-certs-category__id__exact17-data.csv 
Part 3. Import CCMS public data after 09.2014: ccms_refrigerator_archived_post_092014.csv same as p-certs-category__id__exact17-data.csv but after JSON extraction
refrigerators_ccmspublic.csv 
Part 4. Check what p-certs (Part 2.) data are about. 
Part 5. Import Prospector data: productData.csv
Part 6. Merge CCMS and Prospector data
*/

pause on

global  pathdata_1 = "/Users/shoude/Dropbox/eegap/EEgap_data/Prospector_LBNL"
*global  pathdata_2 = "/Users/shoude/Dropbox/eegap/EEgap_data_code_heter_SM/Results_estimation"
global  pathresults = "/Users/shoude/Dropbox/eegap/EEgap_data_code_heter_SM/Results_estimation"

*global  pathresults ="/Volumes/RECHERCHE/FAC/HEC/DEEP/shoude/default/D2c/eegap/EEgap_data_code_heter_SM/Results_Estimation"
*global  Est_pathresults = "/Volumes/RECHERCHE/FAC/HEC/DEEP/shoude/default/D2c/eegap/EEgap_data_code_heter_SM/Results_Estimation"

//==============================================================================
//Part 1. Import CCMS private data prior 09.2014
//==============================================================================

insheet using $pathdata_1/ccms_refrigerator_archived_pre_092014.csv, comma clear name 

 destring annualenergyusekhperyear volumeadjustedcuf productclassdescription, force replace
 split datecertified, parse(.)
 ren datecertified1 day_certified
 ren datecertified2 month_certified
 ren datecertified3 year_certified
 gen y20="20"
 replace year_certified = y20 + year_certified
 destring *_certified, replace  force
 drop y20
 
 ren annualenergyusekhperyear kwh_y
 ren volumeadjustedcuf AV
 gen meps_2001 = 8.82*AV + 248.4
 replace meps_2001 = 9.80*AV + 276.0 if productclassdescription == 3
 replace meps_2001 = 4.91*AV + 507.5 if productclassdescription == 4
 replace meps_2001 = 4.60*AV + 459.0 if productclassdescription == 5
 replace meps_2001 = 10.2*AV + 356.0 if productclassdescription == 6
 replace meps_2001 = 10.10*AV + 406.0 if productclassdescription == 7
 replace meps_2001 = 7.55*AV + 258.3 if productclassdescription == 8 
 replace meps_2001 = 12.43*AV + 326.1 if productclassdescription == 9
 replace meps_2001 = 9.88*AV + 143.7 if productclassdescription == 10
 replace meps_2001 = 10.70*AV + 299.0 if productclassdescription == 11
 replace meps_2001 = 7.00*AV + 398.0 if productclassdescription == 12
 replace meps_2001 = 12.70*AV + 355.0 if productclassdescription == 13
 replace meps_2001 = 7.60*AV + 501.0 if productclassdescription == 14
 replace meps_2001 = 13.10*AV + 367.0 if productclassdescription == 15
 replace meps_2001 = 9.78*AV + 250.8 if productclassdescription == 16
 replace meps_2001 = 11.40*AV + 391.0 if productclassdescription == 17
 replace meps_2001 = 10.45*AV + 152.0 if productclassdescription == 18 
  
  ren modelnumbasic mpn_basic
  ren modelnumindividualcoveredbybasic mpn_detailed
  ren productclassdescription pd_class_pre_2014
  sort mpn_detailed
  egen id_pre_092014=seq()
save $pathdata_1/ccms_refrigerator_pre_092014, replace 
  
//==============================================================================
//Part 2. Import p-certs data after 09.2014 
//Not Needed: No new information relative to post-data
//==============================================================================  
/*  
insheet using $pathdata_1/p-certs-category__id__exact17-data_extracted.csv, comma clear name   
  
 split _last_lbl_collection_time, parse(" ")
 split _last_lbl_collection_time1, parse("-")
 ren _last_lbl_collection_time11 year_certified
 ren _last_lbl_collection_time12 month_certified
 ren _last_lbl_collection_time13 day_certified
 destring *_certified, replace force
 
 drop datecertified
 ren _last_lbl_collection_time1 datecertified

 ren annualenergyuse_kilowatthoursyea kwh_y
 ren totaladjustedvolume_cubicfeet AV
 ren totalrefrigeratedvolume_ft3 volume_ft3
  
 destring kwh_y AV volume_ft3, force replace

 split productgroupcodedescription, parse(")")
 split productgroupcodedescription1, parse("(")
 tab productgroupcodedescription12
 ren productgroupcodedescription12 productgroupcodedescription_id
 drop productgroupcodedescription1 productgroupcodedescription2 productgroupcodedescription11

 gen meps_2014 = 7.99*AV + 225.0
 replace meps_2014 = 6.79*AV + 193.6 if productgroupcodedescription_id == "1A."
 replace meps_2014 = 7.99*AV + 225.0 if productgroupcodedescription_id == "2."
 replace meps_2014 = 8.07*AV + 233.7 if productgroupcodedescription_id == "3."
 replace meps_2014 = 7.07*AV + 201.6 if productgroupcodedescription_id == "3A."
 replace meps_2014 = 8.07*AV + 317.7 if productgroupcodedescription_id == "3I."
 replace meps_2014 = 9.15*AV + 264.9 if productgroupcodedescription_id == "3-BI."
 replace meps_2014 = 8.02*AV + 228.5 if productgroupcodedescription_id == "3A-BI."
 replace meps_2014 = 9.15*AV + 348.9 if productgroupcodedescription_id == "3I-BI."
 replace meps_2014 = 8.51*AV + 297.8 if productgroupcodedescription_id == "4."
 replace meps_2014 = 8.51*AV + 381.8 if productgroupcodedescription_id == "4I."
 replace meps_2014 = 10.22*AV + 357.4 if productgroupcodedescription_id == "4-BI."
 replace meps_2014 = 10.22*AV + 441.4 if productgroupcodedescription_id == "4I-BI."
 replace meps_2014 = 8.85*AV + 317.0 if productgroupcodedescription_id == "5."
 replace meps_2014 = 9.25*AV + 475.4 if productgroupcodedescription_id == "5A."
 replace meps_2014 = 8.85*AV + 401.0 if productgroupcodedescription_id == "5I."
 replace meps_2014 = 9.40*AV + 336.9 if productgroupcodedescription_id == "5-BI."
 replace meps_2014 = 9.83*AV + 499.9 if productgroupcodedescription_id == "5A-BI."
 replace meps_2014 = 9.40*AV + 420.9 if productgroupcodedescription_id == "5I-BI."
 replace meps_2014 = 8.40*AV + 385.4 if productgroupcodedescription_id == "6."
 replace meps_2014 = 8.54*AV + 432.8 if productgroupcodedescription_id == "7."
 replace meps_2014 = 10.25*AV + 502.6 if productgroupcodedescription_id == "7-BI."
 replace meps_2014 = 5.57*AV + 193.7 if productgroupcodedescription_id == "8." 
 replace meps_2014 = 8.62*AV + 228.3 if productgroupcodedescription_id == "9."
 replace meps_2014 = 8.62*AV + 312.3 if productgroupcodedescription_id == "9I."
 replace meps_2014 = 9.86*AV + 260.9 if productgroupcodedescription_id == "9-BI."
 replace meps_2014 = 9.86*AV + 344.9 if productgroupcodedescription_id == "9I-BI."
 replace meps_2014 = 7.29*AV + 107.8 if productgroupcodedescription_id == "10."
 replace meps_2014 = 10.24*AV + 148.1 if productgroupcodedescription_id == "10A."
 replace meps_2014 = 9.03*AV + 252.3 if productgroupcodedescription_id == "11."
 replace meps_2014 = 7.84*AV + 219.1 if productgroupcodedescription_id == "11A."
 replace meps_2014 = 5.91*AV + 335.8 if productgroupcodedescription_id == "12."
 replace meps_2014 = 11.80*AV + 339.2 if productgroupcodedescription_id == "13."
 replace meps_2014 = 9.17*AV + 259.3 if productgroupcodedescription_id == "13A."
 replace meps_2014 = 11.80*AV + 423.2 if productgroupcodedescription_id == "13I."
 replace meps_2014 = 6.82*AV + 456.9 if productgroupcodedescription_id == "14."
 replace meps_2014 = 6.82*AV + 540.9 if productgroupcodedescription_id == "14I."
 replace meps_2014 = 11.80*AV + 339.2 if productgroupcodedescription_id == "15."
 replace meps_2014 = 11.80*AV + 423.2 if productgroupcodedescription_id == "15I."
 replace meps_2014 = 8.65*AV + 225.7 if productgroupcodedescription_id == "16."
 replace meps_2014 = 10.17*AV + 351.9 if productgroupcodedescription_id == "17."
 replace meps_2014 = 9.25*AV + 136.8 if productgroupcodedescription_id == "18." 
 
 ren productgroupcodedescription pd_class_post_2014

 ren basicmodelnumber mpn_basic
 replace mpn_basic = modelnumbasic if mpn_basic == "NA" & modelnumbasic != "NA"
  
 ren individualmodelnumbercoveredbyba mpn_detailed
 replace mpn_detailed = modelnumindividualcoveredbybasic if mpn_detailed == "NA" & modelnumindividualcoveredbybasic != "NA"

 drop brand
 ren brandname brand 
 
 keep datecertified brand mpn_basic mpn_detailed kwh_y AV pd_class_post_2014 manufacturer day_certified month_certified year_certified meps_2014
 sort mpn_basic
 egen id_pcert_092014=seq()
save $pathdata_1/pcert_refrigerator_post_092014, replace 
*/

//==============================================================================
//Part 3. Import CCMS public data after 09.2014
//==============================================================================  
  
insheet using $pathdata_1/refrigerators_ccmspublic.csv, comma clear name  

 split _last_lbl_collection_time, parse(" ")
 split _last_lbl_collection_time1, parse("-")
 ren _last_lbl_collection_time11 year_certified
 ren _last_lbl_collection_time12 month_certified
 ren _last_lbl_collection_time13 day_certified
 *gen y20="20"
 *replace year_certified = y20 + year_certified
 destring *_certified, replace  force
 *drop y20
 ren _last_lbl_collection_time1 datecertified

 ren annualenergyuse_kilowatthoursyea kwh_y
 ren totaladjustedvolume_cubicfeet AV
 ren totalrefrigeratedvolume_ft3 volume_ft3
  
 destring kwh_y AV volume_ft3, force replace

 split productgroupcodedescription, parse(")")
 split productgroupcodedescription1, parse("(")
 tab productgroupcodedescription12
 ren productgroupcodedescription12 productgroupcodedescription_id
 drop productgroupcodedescription1 productgroupcodedescription2 productgroupcodedescription11

 gen meps_2014 = 7.99*AV + 225.0
 replace meps_2014 = 6.79*AV + 193.6 if productgroupcodedescription_id == "1A."
 replace meps_2014 = 7.99*AV + 225.0 if productgroupcodedescription_id == "2."
 replace meps_2014 = 8.07*AV + 233.7 if productgroupcodedescription_id == "3."
 replace meps_2014 = 7.07*AV + 201.6 if productgroupcodedescription_id == "3A."
 replace meps_2014 = 8.07*AV + 317.7 if productgroupcodedescription_id == "3I."
 replace meps_2014 = 9.15*AV + 264.9 if productgroupcodedescription_id == "3-BI."
 replace meps_2014 = 8.02*AV + 228.5 if productgroupcodedescription_id == "3A-BI."
 replace meps_2014 = 9.15*AV + 348.9 if productgroupcodedescription_id == "3I-BI."
 replace meps_2014 = 8.51*AV + 297.8 if productgroupcodedescription_id == "4."
 replace meps_2014 = 8.51*AV + 381.8 if productgroupcodedescription_id == "4I."
 replace meps_2014 = 10.22*AV + 357.4 if productgroupcodedescription_id == "4-BI."
 replace meps_2014 = 10.22*AV + 441.4 if productgroupcodedescription_id == "4I-BI."
 replace meps_2014 = 8.85*AV + 317.0 if productgroupcodedescription_id == "5."
 replace meps_2014 = 9.25*AV + 475.4 if productgroupcodedescription_id == "5A."
 replace meps_2014 = 8.85*AV + 401.0 if productgroupcodedescription_id == "5I."
 replace meps_2014 = 9.40*AV + 336.9 if productgroupcodedescription_id == "5-BI."
 replace meps_2014 = 9.83*AV + 499.9 if productgroupcodedescription_id == "5A-BI."
 replace meps_2014 = 9.40*AV + 420.9 if productgroupcodedescription_id == "5I-BI."
 replace meps_2014 = 8.40*AV + 385.4 if productgroupcodedescription_id == "6."
 replace meps_2014 = 8.54*AV + 432.8 if productgroupcodedescription_id == "7."
 replace meps_2014 = 10.25*AV + 502.6 if productgroupcodedescription_id == "7-BI."
 replace meps_2014 = 5.57*AV + 193.7 if productgroupcodedescription_id == "8." 
 replace meps_2014 = 8.62*AV + 228.3 if productgroupcodedescription_id == "9."
 replace meps_2014 = 8.62*AV + 312.3 if productgroupcodedescription_id == "9I."
 replace meps_2014 = 9.86*AV + 260.9 if productgroupcodedescription_id == "9-BI."
 replace meps_2014 = 9.86*AV + 344.9 if productgroupcodedescription_id == "9I-BI."
 replace meps_2014 = 7.29*AV + 107.8 if productgroupcodedescription_id == "10."
 replace meps_2014 = 10.24*AV + 148.1 if productgroupcodedescription_id == "10A."
 replace meps_2014 = 9.03*AV + 252.3 if productgroupcodedescription_id == "11."
 replace meps_2014 = 7.84*AV + 219.1 if productgroupcodedescription_id == "11A."
 replace meps_2014 = 5.91*AV + 335.8 if productgroupcodedescription_id == "12."
 replace meps_2014 = 11.80*AV + 339.2 if productgroupcodedescription_id == "13."
 replace meps_2014 = 9.17*AV + 259.3 if productgroupcodedescription_id == "13A."
 replace meps_2014 = 11.80*AV + 423.2 if productgroupcodedescription_id == "13I."
 replace meps_2014 = 6.82*AV + 456.9 if productgroupcodedescription_id == "14."
 replace meps_2014 = 6.82*AV + 540.9 if productgroupcodedescription_id == "14I."
 replace meps_2014 = 11.80*AV + 339.2 if productgroupcodedescription_id == "15."
 replace meps_2014 = 11.80*AV + 423.2 if productgroupcodedescription_id == "15I."
 replace meps_2014 = 8.65*AV + 225.7 if productgroupcodedescription_id == "16."
 replace meps_2014 = 10.17*AV + 351.9 if productgroupcodedescription_id == "17."
 replace meps_2014 = 9.25*AV + 136.8 if productgroupcodedescription_id == "18." 
 
 ren productgroupcodedescription pd_class_post_2014

 ren basicmodelnumber mpn_basic
  
 ren individualmodelnumbercoveredbyba mpn_detailed

 ren brandname brand 
 
 keep datecertified brand mpn_basic mpn_detailed kwh_y AV pd_class_post_2014 day_certified month_certified year_certified meps_2014 
 sort mpn_detailed
 egen id_post_092014=seq()
save $pathdata_1/ccms_refrigerator_post_092014, replace  


 
//==============================================================================
//Part 4. Merge CCMS data with P-cert
//============================================================================== 


use $pathdata_1/ccms_refrigerator_pre_092014, clear 
	keep if kwh_y != .
save $pathdata_1/ccms_refrigerator_pre_092014_w_kwh, replace

use $pathdata_1/ccms_refrigerator_post_092014, clear 
	keep if kwh_y != .
save $pathdata_1/ccms_refrigerator_post_092014_w_kwh, replace
	append using $pathdata_1/ccms_refrigerator_pre_092014_w_kwh
	duplicates tag brand mpn_basic mpn_detailed kwh_y AV, generate(dup_tag)
	tab dup_tag
	drop if dup_tag >=1
	drop dup_tag
	sort mpn_basic
save $pathdata_1/ccms_refrigerator_pre_post_092014_w_kwh, replace
	
pause
	
use $pathdata_1/ccms_refrigerator_pre_092014, clear 
	keep if kwh_y == .
save $pathdata_1/ccms_refrigerator_pre_092014_no_kwh, replace

use $pathdata_1/ccms_refrigerator_post_092014, clear 
	keep if kwh_y == .
save $pathdata_1/ccms_refrigerator_post_092014_no_kwh, replace
	append using $pathdata_1/ccms_refrigerator_pre_092014_no_kwh
	duplicates tag brand mpn_basic mpn_detailed kwh_y AV, generate(dup_tag)
	tab dup_tag
	drop if dup_tag >=1
	drop dup_tag
	sort mpn_basic
save $pathdata_1/ccms_refrigerator_pre_post_092014_no_kwh, replace	
	
	
//==============================================================================
//Part 5. Merge CCMS data (Part 4) with PROSPECTOR Data
//==============================================================================


use $pathdata_1/ccms_refrigerator_pre_post_092014_w_kwh, clear
	sort mpn_detailed
save $pathdata_1/ccms_refrigerator_pre_post_092014_w_kwh, replace

use $pathdata_1/ccms_refrigerator_pre_post_092014_w_kwh, clear
	sort mpn_basic
save $pathdata_1/ccms_refrigerator_pre_post_092014_w_kwh_tmp, replace


insheet using $pathdata_1/Prospector/productData.csv, clear

pause
	ren brand brand_prospector
	ren mpn mpn_detailed
	sort mpn_detailed
	merge mpn_detailed using $pathdata_1/ccms_refrigerator_pre_post_092014_w_kwh
	tab _m
	drop if _m == 2
	ren _m merge_ccms_detailed_092014
	
	sum kwh_y
pause
	
	ren mpn_detailed mpn
	*ren doe_model_num_basic 
	ren doe_model_num_individual mpn_detailed 
	
	sort mpn_detailed
	merge mpn_detailed using $pathdata_1/ccms_refrigerator_pre_post_092014_w_kwh
	tab _m
	drop if _m == 2
	ren _m merge_doe_ccms_detailed_092014
	
	sum kwh_y
	
	drop mpn_basic
	ren mpn mpn_basic
	sort mpn_basic
	merge mpn_basic using $pathdata_1/ccms_refrigerator_pre_post_092014_w_kwh_tmp
	tab _m
	drop if _m == 2
	ren _m merge_ccms_basic_092014
	tab merge_ccms_basic_092014 merge_ccms_detailed_092014
	
	sum kwh_y
	
	ren mpn_basic mpn
	ren doe_model_num_basic mpn_basic
	
	sort mpn_basic
	merge mpn_basic using $pathdata_1/ccms_refrigerator_pre_post_092014_w_kwh_tmp
	tab _m
	drop if _m == 2
	ren _m merge_doe_ccms_basic_092014
	
/*
We could then try more sophisticated matching using part of the model number. 
*/
		
	sum kwh_y
	gen kwh_y_tmp = kwh_y
	replace kwh_y_tmp = doe_energykwhperyear if kwh_y == .
	sum kwh_y_tmp
	drop kwh_y
	ren kwh_y_tmp kwh_y
	
	destring doe_adjusted_volume_cu_ft, replace force
	sum doe_adjusted_volume_cu_ft AV
	gen AV_tmp = AV
	replace AV_tmp = doe_adjusted_volume_cu_ft if AV == .
	sum AV_tmp
	drop AV
	ren AV_tmp AV
	
 split doe_product_class, parse(")")
 split doe_product_class1, parse("(")
 tab doe_product_class12
 ren doe_product_class12 doe_product_class_id
 drop doe_product_class1 doe_product_class2 doe_product_class11

 *gen meps_2014 = 7.99*AV + 225.0
 replace meps_2014 = 6.79*AV + 193.6 if doe_product_class_id == "1A."
 replace meps_2014 = 7.99*AV + 225.0 if doe_product_class_id == "2."
 replace meps_2014 = 8.07*AV + 233.7 if doe_product_class_id == "3."
 replace meps_2014 = 7.07*AV + 201.6 if doe_product_class_id == "3A."
 replace meps_2014 = 8.07*AV + 317.7 if doe_product_class_id == "3I."
 replace meps_2014 = 9.15*AV + 264.9 if doe_product_class_id == "3-BI."
 replace meps_2014 = 8.02*AV + 228.5 if doe_product_class_id == "3A-BI."
 replace meps_2014 = 9.15*AV + 348.9 if doe_product_class_id == "3I-BI."
 replace meps_2014 = 8.51*AV + 297.8 if doe_product_class_id == "4."
 replace meps_2014 = 8.51*AV + 381.8 if doe_product_class_id == "4I."
 replace meps_2014 = 10.22*AV + 357.4 if doe_product_class_id == "4-BI."
 replace meps_2014 = 10.22*AV + 441.4 if doe_product_class_id == "4I-BI."
 replace meps_2014 = 8.85*AV + 317.0 if doe_product_class_id == "5."
 replace meps_2014 = 9.25*AV + 475.4 if doe_product_class_id == "5A."
 replace meps_2014 = 8.85*AV + 401.0 if doe_product_class_id == "5I."
 replace meps_2014 = 9.40*AV + 336.9 if doe_product_class_id == "5-BI."
 replace meps_2014 = 9.83*AV + 499.9 if doe_product_class_id == "5A-BI."
 replace meps_2014 = 9.40*AV + 420.9 if doe_product_class_id == "5I-BI."
 replace meps_2014 = 8.40*AV + 385.4 if doe_product_class_id == "6."
 replace meps_2014 = 8.54*AV + 432.8 if doe_product_class_id == "7."
 replace meps_2014 = 10.25*AV + 502.6 if doe_product_class_id == "7-BI."
 replace meps_2014 = 5.57*AV + 193.7 if doe_product_class_id == "8." 
 replace meps_2014 = 8.62*AV + 228.3 if doe_product_class_id == "9."
 replace meps_2014 = 8.62*AV + 312.3 if doe_product_class_id == "9I."
 replace meps_2014 = 9.86*AV + 260.9 if doe_product_class_id == "9-BI."
 replace meps_2014 = 9.86*AV + 344.9 if doe_product_class_id == "9I-BI."
 replace meps_2014 = 7.29*AV + 107.8 if doe_product_class_id == "10."
 replace meps_2014 = 10.24*AV + 148.1 if doe_product_class_id == "10A."
 replace meps_2014 = 9.03*AV + 252.3 if doe_product_class_id == "11."
 replace meps_2014 = 7.84*AV + 219.1 if doe_product_class_id == "11A."
 replace meps_2014 = 5.91*AV + 335.8 if doe_product_class_id == "12."
 replace meps_2014 = 11.80*AV + 339.2 if doe_product_class_id == "13."
 replace meps_2014 = 9.17*AV + 259.3 if doe_product_class_id == "13A."
 replace meps_2014 = 11.80*AV + 423.2 if doe_product_class_id == "13I."
 replace meps_2014 = 6.82*AV + 456.9 if doe_product_class_id == "14."
 replace meps_2014 = 6.82*AV + 540.9 if doe_product_class_id == "14I."
 replace meps_2014 = 11.80*AV + 339.2 if doe_product_class_id == "15."
 replace meps_2014 = 11.80*AV + 423.2 if doe_product_class_id == "15I."
 replace meps_2014 = 8.65*AV + 225.7 if doe_product_class_id == "16."
 replace meps_2014 = 10.17*AV + 351.9 if doe_product_class_id == "17."
 replace meps_2014 = 9.25*AV + 136.8 if doe_product_class_id == "18." 
	
/*
Extract dates on the market and entry dates
*/
split first_collection_timestamp, parse(" ")
split latest_collection_timestamp, parse(" ")

gen date_first_collection  = date(first_collection_timestamp1, "MDY")
gen year_first_collection  = year(date_first_collection)
gen month_first_collection = month(date_first_collection)
gen day_first_collection   = day(date_first_collection)

gen date_last_collection  = date(latest_collection_timestamp1, "MDY")
gen year_last_collection  = year(date_last_collection)
gen month_last_collection = month(date_last_collection)
gen day_last_collection   = day(date_last_collection)

gen duration_scrap = date_last_collection - date_first_collection

	
split pd_class_post_2014, parse(")")	

gen type=""
replace	type="Top Freezer" if pd_class_pre_2014==3 | pd_class_pre_2014==6 | pd_class_post_20141=="(3." | pd_class_post_20141=="(3-BI." | pd_class_post_20141=="(3I." 

replace	type="Side Freezer" if pd_class_pre_2014==4 | pd_class_pre_2014==7 | pd_class_post_20141=="(4." | pd_class_post_20141=="(7." | pd_class_post_20141=="(4I." | pd_class_post_20141=="(4I-BI." | pd_class_post_20141=="(7-BI." 	

replace	type="Bottom Freezer" if pd_class_pre_2014==5 | pd_class_post_20141=="(5." | pd_class_post_20141=="(5A." | pd_class_post_20141=="(5I." | pd_class_post_20141=="(5I-BI." | pd_class_post_20141=="(5-BI."  

replace	type="Compact Fridge" if pd_class_pre_2014==11 | pd_class_pre_2014==12 | pd_class_pre_2014==13 | pd_class_pre_2014==14 | pd_class_post_20141=="(11." | pd_class_post_20141=="(11A." | pd_class_post_20141=="(12." | pd_class_post_20141=="(13." | pd_class_post_20141=="(13A."  | pd_class_post_20141=="(13I." | pd_class_post_20141=="(14."  | pd_class_post_20141=="(14I."  | pd_class_post_20141=="(15."  | pd_class_post_20141=="(15I."  


save $pathdata_1/Prospector_productData_w_attributes, replace

